Soholaunch Company Blog

2 Time-Saving Tools for Plugin Developers

1. The testArray() function

What it does

Displays the contents of an array in a nicely-formatted table. Easier than print_r() in many ways because formatting is identical every time.

Example Usage

Example Output

Notes

  • You can treat the output of testArray() like a variable. You can return it or you can print it. It does not automatically print.
  • Will only output up to two deminsions, which is perfect for most projects. But if you need to output more, just use print_r()
  • Available globally, in the admin and on the website itself.


2. The $report[] array

What it does

For use in admin modules, the $report array captures all of your error messages, success messages, and general reports, then outputs them in a consistent format when the admin module loads. Use this so you don’t have to worry about writing your own way of outputting error messages and such.

Example Usage

Notes

  • You can add messages to the $report array any time in your script, as long as it’s before the bottom when you call the smt_module functions that build the admin module html (see sohoadmin/program/modules/sample_module.php)
  • HTML is allowed the report messages
  • You can add multiple messages to the $report array, and it will display them in a bullet list.
  • Report display will auto-hide on click